@echo off
cd /d %~dp0

REM Initialize development environment
call "checkEnv.bat"

REM Create build directory if not exists
if not exist build_cmake mkdir build_cmake
if not exist x64 mkdir x64

REM Generate build files using CMake
cd build_cmake
cmake -G "Visual Studio 16 2019" -A x64 ..

REM Wait for user to continue
echo CMake configuration completed. Press any key to continue with build...

REM Build the project using MSBuild
msbuild HelloCmake.sln /p:Configuration=Release /p:Platform=x64

REM Check if the build was successful
if exist "Release\HelloCmake.exe" (
    copy "Release\HelloCmake.exe" "..\x64\HelloCmake.exe" /Y
    echo Build successful: x64\HelloCmake.exe created
) else (
    echo Build failed: Release\HelloCmake.exe not found
)

cd ..
echo Build process completed
pause 